<template>
    <div>
        <cesium-container :newArr3="newArr3" :newArr5="newArr5" :newArr7="newArr7"></cesium-container>
        <province-header>
        </province-header>
        <div class="provinceLeft">
            <left-contentOne
                :StationTypeCounts="StationTypeCounts"
                :FYLZStationBCMIDJCounts="FYLZStationBCMIDJCounts"
                :FYLZStationHCIDJCounts="FYLZStationHCIDJCounts"
                :FYLZStationWCIDJCounts="FYLZStationWCIDJCounts"
                :FYLZStationTHIDJCounts="FYLZStationTHIDJCounts"
            ></left-contentOne>
            <left-contentTwo 
                :BCMIBestCity="BCMIBestCity"
                :HCIBestCity="HCIBestCity"
                :THIBestCity="THIBestCity"
                :WCIBestCity="WCIBestCity"
            ></left-contentTwo>
            <left-contentThree
                :CityStationBCMIDJCounts="CityStationBCMIDJCounts"
                :CityStationHCIDJCounts="CityStationHCIDJCounts"
                :CityStationTHIDJCounts="CityStationTHIDJCounts"
                :CityStationWCIDJCounts="CityStationWCIDJCounts"
            ></left-contentThree>   
        </div>
        <right-tool></right-tool>
        <common-bottom></common-bottom>
        <common-controlBtn></common-controlBtn>
        <common-color></common-color>
    </div>
</template>
<script> 
import CesiumContainer from '../cesium/CesiumContainer'
import ProvinceHeader from './components/ProvinceHeader'
import RightTool from '../commons/RightTool'
import LeftContentOne from './components/LeftContentOne'
import LeftContentTwo from './components/LeftContentTwo'
import LeftContentThree from './components/LeftContentThree'
import CommonBottom from '../commons/CommonBottom'
import CommonControlBtn from './components/CommonControlBtn'
import HeaderCenter from '../commons/components/HeaderCenter'
import CommonColor from '../commons/CommonColor'

import axios from 'axios'
export default {
    name: 'Province',
    components: {
        CesiumContainer,
        ProvinceHeader,
        LeftContentOne,
        LeftContentTwo,
        LeftContentThree,
        RightTool,
        CommonBottom,
        CommonControlBtn,
        HeaderCenter,
        CommonColor
    },
    data(){
        return{
            timer:null,
            BCMIBestCity:[],
            HCIBestCity:[],
            THIBestCity:[],
            WCIBestCity:[],
            newArr3:[],
            newArr5:[],
            newArr7:[],
            StationTypeCounts:[],
            CityStationBCMIDJCounts:[],
            CityStationHCIDJCounts:[],
            CityStationTHIDJCounts:[],
            CityStationWCIDJCounts:[],
            FYLZStationBCMIDJCounts:[],
            FYLZStationHCIDJCounts:[],
            FYLZStationWCIDJCounts:[],
            FYLZStationTHIDJCounts:[]
            
        }
    },
    methods: {
        getProvinceData(){
            if(this.$comjs.isOnline){
                axios.get('/apis/api/QX/GetQXProvinceInfo').then(
                    this.getProvinceDataInfo
                )
            }else{
                axios.get(this.$comjs.qhzsPro).then(
                    this.getProvinceDataInfo
                )
            }
            
            
        },
        getProvinceDataInfo(res){
            //之后更改
            if(res.data.CityQXZs){
                this.newArr3 = res.data.CityQXZs;
            }
            if(res.data.StationQXZs){
                this.newArr5 = res.data.StationQXZs;
            }
            if(res.data.CountryQXZs){
                this.newArr7 = res.data.CountryQXZs;
            }
            if(res.data.FYLZStationBCMIDJCounts){
                this.FYLZStationBCMIDJCounts=res.data.FYLZStationBCMIDJCounts
            }
            if(res.data.FYLZStationHCIDJCounts){
                this.FYLZStationHCIDJCounts=res.data.FYLZStationHCIDJCounts
            }
            if(res.data.FYLZStationWCIDJCounts){
                this.FYLZStationWCIDJCounts=res.data.FYLZStationWCIDJCounts
            }
            if(res.data.FYLZStationTHIDJCounts){
                this.FYLZStationTHIDJCounts=res.data.FYLZStationTHIDJCounts
            }
            if(res.data.StationTypeCounts){
                this.StationTypeCounts = res.data.StationTypeCounts
            }
            
            if(res.data.BCMIHourBestCity && res.data.BCMIDayBestCity && res.data.BCMIMonthBestCity && res.data.BCMIQuarterBestCity){
                 this.BCMIBestCity = [res.data.BCMIHourBestCity,res.data.BCMIDayBestCity, res.data.BCMIMonthBestCity,res.data.BCMIQuarterBestCity]
            }
            if(res.data.HCIHourBestCity && res.data.HCIDayBestCity && res.data.HCIMonthBestCity && res.data.HCIQuarterBestCity){
                 this.HCIBestCity = [res.data.HCIHourBestCity, res.data.HCIDayBestCity, res.data.HCIMonthBestCity, res.data.HCIQuarterBestCity]
            }
            if(res.data.THIHourBestCity && res.data.THIDayBestCity && res.data.THIMonthBestCity && res.data.THIQuarterBestCity){
                this.THIBestCity = [res.data.THIHourBestCity,res.data.THIDayBestCity,res.data.THIMonthBestCity,res.data.THIQuarterBestCity]
            }
            if(res.data.WCIHourBestCity && res.data.WCIDayBestCity && res.data.WCIMonthBestCity && res.data.WCIQuarterBestCity){
                this.WCIBestCity = [res.data.WCIHourBestCity,res.data.WCIDayBestCity,res.data.WCIMonthBestCity,res.data.WCIQuarterBestCity] 
            }

            if(res.data.CityStationBCMIDJCounts){
                this.CityStationBCMIDJCounts = res.data.CityStationBCMIDJCounts
            }  
            if(res.data.CityStationHCIDJCounts){
                this.CityStationHCIDJCounts = res.data.CityStationHCIDJCounts
            }  
            if(res.data.CityStationTHIDJCounts){
                this.CityStationTHIDJCounts = res.data.CityStationTHIDJCounts
            }  
            if(res.data.CityStationWCIDJCounts){
                this.CityStationWCIDJCounts = res.data.CityStationWCIDJCounts
            }  
            if(res.data.Regions){
                this.$store.commit("changeCities",res.data.Regions)
            }  
        },
        andUpdata(){
         this.getProvinceData()//在整点执行的函数，在每个整点都调用该函数
         this.timer =  setInterval(()=>{this.getProvinceData()},60*60*1000);//一个小时执行一次，那么下一个整点，下下一个整点都会执行
        }
    },
    created(){
        this.$store.commit("changeForq",1)
    },
    beforeMount(){
        this.$store.commit("changeForq",1)
    },
    activated(){
        this.$store.commit("changeForq",1)
    },
    beforeDestroy(){
      if(this.timer){
          clearInterval(this.timer)
        }
    },
    mounted(){
        this.getProvinceData();
        var date = new Date();//现在时刻
        var dateIntegralPoint = new Date();//用户登录时刻的下一个整点，也可以设置成某一个固定时刻
        dateIntegralPoint.setHours(date.getHours()+1);//小时数增加1
        dateIntegralPoint.setMinutes(10);
        dateIntegralPoint.setSeconds(0);
        console.log(dateIntegralPoint);
        console.log(dateIntegralPoint-date);
        console.log((dateIntegralPoint-date)/60000);
        setTimeout(()=>{this.andUpdata()},dateIntegralPoint-date);//用户登录后的下一个整点执行。
        // this.$comjs.addQ();
        this.$comjs.onCenter(119.906064,29.573401,901893.0)
    }
}
</script>
<style >
    .provinceLeft{
        position: absolute;
        left: 0;
        top: 6.57vh;
        z-index: 2;
        width: 4.02rem;
        /*height: calc(100% - 1.32rem); 12.2vh*/
        height: 87.8vh;
    }
</style>

